/**
 * \file CDiff.h
 * \author Corentin Le Bail
 * \date 2009-2012
 * \brief Fichier de déclaration de la class CDiff
 */
//------------------------------------------------------------------------------
#ifndef __CDIFF_H__
#define __CDIFF_H__
//------------------------------------------------------------------------------
#include <QString>
//------------------------------------------------------------------------------
/**
 * \class CDiff CDiff.h "CDiff.h"
 * \brief Classe de différenciation / patch de texte.
 */
class CDiff
{
	public:
		/**
		 * \fn static QString diff(QString text1, QString text2)
		 * \brief Effectue un diff entre text1 et text2
		 * \param[in] text1 Le texte d'origine
		 * \param[in] text2 Le texte de destination
		 * \return Le diff entre les 2 textes
		 */
		static QString diff(QString text1, QString text2);
		/**
		 * \fn static QString merge(QString text, QString with)
		 * \brief Patch text avec with
		 * \param[in] text Le texte d'origine
		 * \param[in] with Le patch
		 * \return Le texte patché
		 */
		static QString merge(QString text, QString with);
	private:
		class CDiffResult
		{
			public:
				CDiffResult(char action) { this->action=action; fromSource=toSource=fromDest=toDest=0; }
				
				char getAction(void) { return action; }
				void setFromSource(int fromSource) { this->fromSource=fromSource; }
				int getToSource(void) { return toSource; }
				void setToSource(int toSource) { this->toSource=toSource; }
				int getFromSource(void) { return fromSource; }
				void setFromDest(int fromDest) { this->fromDest=fromDest; }
				int getFromDest(void) { return fromDest; }
				void setToDest(int toDest) { this->toDest=toDest; }
				int getToDest(void) { return toDest; }
			private:
				char action;
				int fromSource, toSource, fromDest, toDest;
		};
};
//------------------------------------------------------------------------------
#endif //__CDIFF_H__
//------------------------------------------------------------------------------
